let app = getApp();
let that = null;
let config = app.globalData.config;
import {
	post
} from "@/common/js/http.js";
export default {
	data() {
		return {
			title: '试卷中心',
			isLoad: false,
			paperList: []
		};
	},
	onLoad(options) {
		that = this;
		const {
			title = ''
		} = options || {};
		console.log(title);
		if (title != '') {
			that.title = title;
		}
		that.getList(options);
	},
	onShow(options) {
		that = this;
	},
	methods: {
		async getList(options) {
			const {
				course_id = 0
			} = options || {};
			const {
				category_id = 0
			} = options || {};
			let data = {
				course_id: course_id,
				category_id: category_id
			};
			const res = await post('paper/list', data);
			that.paperList = res.data;
			that.isLoad = true;
		},
		itemTap(item) {
			if (item.question_count == 0) {
				app.showToast('试卷暂未上传题目');
				return;
			}
			let url =
				'/pages/practice/topic/topic?title=' +
				item.name +
				'&id=' +
				item.course_id +
				'&extend_id=' +
				item.id +
				'&mainType=8' +
				'&max_page=' +
				item.max_page +
				'&question_type=0' +
				'&chargeType=0';
				console.log(url);
			uni.navigateTo({
				url: url
			});
		}
	}
};